//
//  NSString+LSTBase64.m
//  23_加密
//
//  Created by dllo on 16/8/16.
//  Copyright © 2016年 LST. All rights reserved.
//

#import "NSString+LSTBase64.h"

@implementation NSString (LSTBase64)


- (NSString *)stringWithBase64 {
    NSData *strData = [self dataUsingEncoding:NSUTF8StringEncoding];
    // NSData转nssTeing, 生成字符串
   NSString *base64String = [strData base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
    return base64String;
}
- (NSData *)base64StringWithData {
    return [[NSData alloc]initWithBase64EncodedString:self options:NSDataBase64DecodingIgnoreUnknownCharacters];
}

- (NSString *)base64WithString {
    // 根据Base64字符串, 生成NSData
    NSData *base64Data = [self base64StringWithData];
    // 把NSData转成字符串
    NSString *orginString = [[NSString alloc] initWithData:base64Data encoding:NSUTF8StringEncoding];
    
    return orginString;
}

@end
